using System;
using DevExpress.ExpressApp;
using FeatureCenter.Module.Navigation;
using DevExpress.ExpressApp.SystemModule;
using DevExpress.ExpressApp.Web.SystemModule;
using DevExpress.ExpressApp.Actions;
using System.Web;

namespace FeatureCenter.Module.Web {
	public class HideViewElementsController : ViewController {
		private NavigationObject navigationObject;
		private void View_ControlsCreating(object sender, EventArgs e) {
			((DetailView)View).RemoveItem("DefaultChildItemsDisplayStyle");
			navigationObject = ObjectSpace.FindObject<NavigationObject>(null);
			navigationObject.IsWebApplication = true;
		}
		protected override void OnActivated() {
			base.OnActivated();
			View.ControlsCreating += new EventHandler(View_ControlsCreating);
		}
		protected override void OnDeactivated() {
			if (View != null) {
				View.ControlsCreating += new EventHandler(View_ControlsCreating);
			}
			base.OnDeactivated();
		}
		public HideViewElementsController() {
			TargetViewType = ViewType.DetailView;
			TargetObjectType = typeof(NavigationObject);
		}
	}
	public class DisableActionsController : ViewController {
		public DisableActionsController() {
			TargetViewType = ViewType.ListView;
			TargetObjectType = typeof(NavigationItem);
		}
		protected override void OnDeactivated() {
			Frame.GetController<ListViewProcessCurrentObjectController>().ProcessCurrentObjectAction.Active["HideViewElementsController"] = true;
			Frame.GetController<ListViewController>().EditAction.Active["HideViewElementsController"] = true;
			base.OnDeactivated();
		}
		protected override void OnActivated() {
			base.OnActivated();
			Frame.GetController<ListViewProcessCurrentObjectController>().ProcessCurrentObjectAction.Active["HideViewElementsController"] = false;
			Frame.GetController<ListViewController>().EditAction.Active["HideViewElementsController"] = false;
		}
	}
}

